package com.yidu.t299.service.xp.impl;
import com.yidu.t299.dao.xp.LogManageMapper;
import com.yidu.t299.domain.xp.LogManage;
import com.yidu.t299.domain.xp.StudentManage;
import com.yidu.t299.service.xp.LogManageBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * @descripion:
 * @auth: XuPan
 * @date: 2023/3/8 19:14
 * @version: 1.0
 */
@Service
@Transactional
public class LogManageBizImpl implements LogManageBiz {
    @Autowired
    private LogManageMapper logManageMapper;//注入数据

    @Override
    public int deleteByPrimaryKey(Integer logId) {
        return logManageMapper.deleteByPrimaryKey(logId);
    }

    @Override
    public int insert(LogManage record) {
        return logManageMapper.insert(record);
    }

    @Override
    public LogManage selectByPrimaryKey(Integer logId) {
        return logManageMapper.selectByPrimaryKey(logId);
    }

    @Override
    public List<LogManage> selectByPage(int rows, int page, String condition) {
        return logManageMapper.selectByPage(rows, page, condition);
    }

    @Override
    public int selectCount(String condition) {
        return logManageMapper.selectCount(condition);
    }

    @Override
    public int updateByPrimaryKey(LogManage record) {
        return logManageMapper.updateByPrimaryKey(record);
    }

    @Override
    public String getCondition(LogManage logManage) {
        // 定义条件字符串变量，初始值为空格字符串
        String condition = " ";
        //如果日志对象为空则直接返回空条件字符串
        if (logManage == null){
            return condition;
        }
        if (logManage.getStudentName() != null && logManage.getStudentName().trim().length()!=0){
            condition += " and student_name like '%" + logManage.getStudentName() + "%'";
        }
        //返回条件字符串
        return condition;
    }

    @Override
    public List<StudentManage> selectAllGetStudent() {
        return logManageMapper.selectAllGetStudent();
    }

    @Override
    public int selectByStudentName(String studentName) {
        return logManageMapper.selectByStudentName(studentName);
    }
}
